﻿using BCEntity.TMS.Agent.AgentAreaRecord;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BCData.TMS.Agent.AgentAreaRecord
{
    /// <summary>
    /// 代理商区域记录
    /// </summary>
    public interface IAgentAreaRecordData
    {
        /// <summary>
        /// 根据代理商记录Id获取代理商区域记录
        /// </summary>
        /// <param name="agentRecordId">代理商记录Id</param>
        /// <returns></returns>
        Task<IEnumerable<AgentAreaRecordEntity>> GetByAgentRecordId(long agentRecordId);
        /// <summary>
        /// 根据代理商记录Id获取代理商区域记录视图
        /// </summary>
        /// <param name="agentRecordId">代理商记录Id</param>
        /// <returns></returns>
        Task<IEnumerable<AgentAreaRecordViewEntity>> GetViewByAgentRecordId(long agentRecordId);
        /// <summary>
        /// 添加代理商区域记录
        /// </summary>
        /// <param name="entity">代理商区域信息</param>
        /// <returns></returns>
        Task<AgentAreaRecordEntity> Insert(AgentAreaRecordEntity entity);

        /// <summary>
        /// 根据代理商记录Id获取代理商区域记录
        /// </summary>
        /// <param name="agentRecordId">代理商记录Id</param>
        /// <returns></returns>
        Task<IEnumerable<AgentAreaRecordEntity>> GetByAgentRecordId(long agentRecordId,string provinceCode,string cityCode, string countyCode);

        /// <summary>
        /// 根据省市区编码获取代理商id
        /// </summary>
        /// <param name="provinceCode">省编码</param>
        /// <param name="cityCode">市编码</param>
        /// <param name="countyCode">区编码</param>
        /// <returns></returns>
        Task<AgentAreaRecordEntity> GetByCode(string provinceCode, string cityCode, string countyCode);


        /// <summary>
        /// 根据省市区编码获取底层代理商id
        /// </summary>
        /// <param name="countyCode">区编码</param>
        /// <returns></returns>
        Task<AgentAreaRecordEntity> GetLastLevelByCode(string countyCode);
        /// <summary>
        /// 获取当前代理商区域下的底层代理信息
        /// </summary>
        /// <param name="agentRecordId">代理商记录Id</param>
        /// <returns></returns>
        Task<IEnumerable<AgentAreaRecordEntity>> AgentAreaExistsList(long? agentRecordId);


        /// <summary>
        /// 根据省市区编码获取底层代理商
        /// </summary>
        /// <param name="agentRecordId">区编码</param>
        /// <param name="countyCode">区编码</param>
        /// <returns></returns>
        Task<AgentAreaRecordEntity> GetByAgentRecordIdAndCountyCode(long agentRecordId, string countyCode);

        /// <summary>
        /// 更新已有子级代理商
        /// </summary>
        /// <param name="agentAreaRecordId">代理商区域记录ID</param>
        /// <param name="countyCode">区县编码</param>
        /// <returns></returns>
        Task<int> UpdateIsChildAgent(long agentAreaRecordId, string countyCode);
    }
}
